package com.accesshollywood.indexables.items;

import com.accesshollywood.grfxOrdering.basics.STATE;
import com.accesshollywood.indexables.GrfxOrder;
import com.accesshollywood.indexables.Indexed;

public class GrfxItem extends Indexed {
	protected GrfxOrder		grfxOrder		= null;
	protected String		filename		= "";
	protected TextSet		textList		= new TextSet();
	protected StillSet		stillList		= new StillSet();
	protected FootageSet	footageList		= new FootageSet();
	protected String		notes			= "";

	protected boolean		needsResearch	= false;
	protected boolean		needsPhotoEdit	= false;
	protected boolean		needsFootage	= false;
	protected boolean		needsLegal		= false;

	protected boolean		apprResearch	= false;
	protected boolean		apprPhotoEdit	= false;
	protected boolean		apprFootage		= false;
	protected boolean		apprLegal		= false;

	@Override
	public void initSQL() {
		setThat(this);
		tableName = "item";
		idColumnName = "idItem";
		elementColumnName.put(getField("filename"), "filename");
		elementColumnName.put(getField("textList"), "idTextList");
		elementColumnName.put(getField("stillList"), "idStillList");
		elementColumnName.put(getField("footageList"), "idFootageList");
		elementColumnName.put(getField("notes"), "notes");

		elementColumnName.put(getField("needsResearch"), "needsResearch");
		elementColumnName.put(getField("needsPhotoEdit"), "needsPhotoEdit");
		elementColumnName.put(getField("needsFootage"), "needsFootage");
		elementColumnName.put(getField("needsLegal"), "needsLegal");

		elementColumnName.put(getField("apprResearch"), "apprResearch");
		elementColumnName.put(getField("apprPhotoEdit"), "apprPhotoEdit");
		elementColumnName.put(getField("apprFootage"), "apprFootage");
		elementColumnName.put(getField("apprLegal"), "apprLegal");
	}

	public String toString() {
		String str = "\n";
		if (!getFilename().equals("")) {
			str += " Filename:  " + getFilename().toString() + "\n";
		}
		if (!getTextList().isEmpty()) {
			str += "\n Text: \n " + getTextList().toString() + "\n";
		}
		if (!getStillList().isEmpty()) {
			str += "\n Photos: \n " + getStillList().toString() + "\n";
		}
		if (!getFootageList().isEmpty()) {
			str += "\n Footage: \n " + getFootageList().toString() + "\n";
		}
		return str;
	}

	public String toPrint() {
		String str = "\n";
		if (!getFilename().equals("")) {
			str += "\n   Filename:  " + getFilename().toString() + "\n";
		}
		if (!getTextList().isEmpty()) {
			str += "\n   Text: \n " + getTextList().toPrint() + "\n";
		}
		if (!getStillList().isEmpty()) {
			str += "\n   Photos: \n " + getStillList().toPrint() + "\n";
		}
		if (!getFootageList().isEmpty()) {
			str += "\n   Footage: \n " + getFootageList().toPrint() + "\n";
		}
		return str;
	}

	public STATE getPhotoEditState() {
		if (apprPhotoEdit) {
			return STATE.APPROVED;
		} else {
			return STATE.WAITING_FOR_PHOTOEDIT;
		}
	}

	public STATE getFootageState() {
		if (apprFootage) {
			return STATE.APPROVED;
		} else {
			return STATE.WAITING_FOR_PHOTOEDIT;
		}
	}

	public synchronized void setGrfxOrder(GrfxOrder newOrder) {
		this.grfxOrder = newOrder;
	}

	public synchronized GrfxOrder getGrfxOrder() {
		return grfxOrder;
	}

	public synchronized String getFilename() {
		return filename;
	}

	public synchronized void setFilename(String filename) {
		this.filename = filename;
	}

	public synchronized TextSet getTextList() {
		return textList;
	}

	public synchronized void setTextList(TextSet textList) {
		this.textList = textList;
	}

	public synchronized StillSet getStillList() {
		return stillList;
	}

	public synchronized void setStillList(StillSet stillList) {
		this.stillList = stillList;
	}

	public synchronized FootageSet getFootageList() {
		return footageList;
	}

	public synchronized void setFootageList(FootageSet footageList) {
		this.footageList = footageList;
	}

	public synchronized String getNotes() {
		return notes;
	}

	public synchronized void setNotes(String notes) {
		this.notes = notes;
	}

	public synchronized boolean needsResearch() {
		return needsResearch;
	}

	public synchronized void setNeedsResearch(boolean needsResearch) {
		this.needsResearch = needsResearch;
	}

	public synchronized boolean needsPhotoEdit() {
		return needsPhotoEdit;
	}

	public synchronized void setNeedsPhotoEdit(boolean needsPhotoEdit) {
		this.needsPhotoEdit = needsPhotoEdit;
	}

	public synchronized boolean needsFootage() {
		return needsFootage;
	}

	public synchronized void setNeedsFootage(boolean needsFootage) {
		this.needsFootage = needsFootage;
	}

	public synchronized boolean isNeedsLegal() {
		return needsLegal;
	}

	public synchronized void setNeedsLegal(boolean needsLegal) {
		this.needsLegal = needsLegal;
	}

	public synchronized boolean isApprResearch() {
		return apprResearch;
	}

	public synchronized void setApprResearch(boolean apprResearch) {
		this.apprResearch = apprResearch;
	}

	public synchronized boolean isApprPhotoEdit() {
		return apprPhotoEdit;
	}

	public synchronized void setApprPhotoEdit(boolean apprPhotoEdit) {
		this.apprPhotoEdit = apprPhotoEdit;
	}

	public synchronized boolean isApprFootage() {
		return apprFootage;
	}

	public synchronized void setApprFootage(boolean apprFootage) {
		this.apprFootage = apprFootage;
	}

	public synchronized boolean isApprLegal() {
		return apprLegal;
	}

	public synchronized void setApprLegal(boolean apprLegal) {
		this.apprLegal = apprLegal;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + (apprFootage ? 1231 : 1237);
		result = prime * result + (apprLegal ? 1231 : 1237);
		result = prime * result + (apprPhotoEdit ? 1231 : 1237);
		result = prime * result + (apprResearch ? 1231 : 1237);
		result = prime * result + ((filename == null) ? 0 : filename.hashCode());
		result = prime * result + ((footageList == null) ? 0 : footageList.hashCode());
		result = prime * result + (needsFootage ? 1231 : 1237);
		result = prime * result + (needsLegal ? 1231 : 1237);
		result = prime * result + (needsPhotoEdit ? 1231 : 1237);
		result = prime * result + (needsResearch ? 1231 : 1237);
		result = prime * result + ((notes == null) ? 0 : notes.hashCode());
		result = prime * result + ((stillList == null) ? 0 : stillList.hashCode());
		result = prime * result + ((textList == null) ? 0 : textList.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		GrfxItem other = (GrfxItem) obj;
		if (apprFootage != other.apprFootage)
			return false;
		if (apprLegal != other.apprLegal)
			return false;
		if (apprPhotoEdit != other.apprPhotoEdit)
			return false;
		if (apprResearch != other.apprResearch)
			return false;
		if (filename == null) {
			if (other.filename != null)
				return false;
		} else if (!filename.equals(other.filename))
			return false;
		if (footageList == null) {
			if (other.footageList != null)
				return false;
		} else if (!footageList.equals(other.footageList))
			return false;
		if (needsFootage != other.needsFootage)
			return false;
		if (needsLegal != other.needsLegal)
			return false;
		if (needsPhotoEdit != other.needsPhotoEdit)
			return false;
		if (needsResearch != other.needsResearch)
			return false;
		if (notes == null) {
			if (other.notes != null)
				return false;
		} else if (!notes.equals(other.notes))
			return false;
		if (stillList == null) {
			if (other.stillList != null)
				return false;
		} else if (!stillList.equals(other.stillList))
			return false;
		if (textList == null) {
			if (other.textList != null)
				return false;
		} else if (!textList.equals(other.textList))
			return false;
		return true;
	}

	/*
	 * DefaultMutableTreeNode {
	 * protected int idItem = -1;
	 * protected NamedList<?> filename = new NamedList<Object>();
	 * protected NamedList<?> textList = new NamedList<Object>();
	 * protected NamedList<?> stillList = new NamedList<Object>();
	 * protected NamedList<?> footageList = new NamedList<Object>();
	 * protected String notes = "";
	 * protected boolean needsResearch;
	 * protected boolean needsPhotoEdit;
	 * protected boolean needsFootage;
	 * protected boolean needsLegal;
	 * protected boolean apprResearch = false;
	 * protected boolean apprPhotoEdit = false;
	 * protected boolean apprFootage = false;
	 * protected boolean apprLegal = false;
	 * protected GrfxOrder grfxOrder;
	 * public GrfxItem() {
	 * }
	 * public STATE getPhotoEditState() {
	 * if (apprPhotoEdit) {
	 * return STATE.APPROVED;
	 * } else {
	 * return STATE.WAITING_FOR_PHOTOEDIT;
	 * }
	 * }
	 * public STATE getFootageState() {
	 * if (apprFootage) {
	 * return STATE.APPROVED;
	 * } else {
	 * return STATE.WAITING_FOR_PHOTOEDIT;
	 * }
	 * }
	 * public void setApprPhotoEdit(boolean newValue) {
	 * apprPhotoEdit = newValue;
	 * }
	 * public void setApprFootage(boolean newValue) {
	 * apprFootage = newValue;
	 * }
	 * public synchronized int getIdItem() {
	 * return idItem;
	 * }
	 * public synchronized void setIdItem(int idItem) {
	 * this.idItem = idItem;
	 * }
	 * public synchronized NamedList<?> getFilename() {
	 * return filename;
	 * }
	 * public synchronized void setFilename(NamedList<?> filename) {
	 * this.filename = filename;
	 * }
	 * public synchronized NamedList<?> getTextList() {
	 * return textList;
	 * }
	 * public synchronized void setTextList(NamedList<?> textList) {
	 * this.textList = textList;
	 * }
	 * public synchronized NamedList<?> getStillList() {
	 * return stillList;
	 * }
	 * public synchronized void setStillList(NamedList<?> stillList) {
	 * this.stillList = stillList;
	 * }
	 * public synchronized NamedList<?> getFootageList() {
	 * return footageList;
	 * }
	 * public synchronized void setFootageList(NamedList<?> footageList) {
	 * this.footageList = footageList;
	 * }
	 * public synchronized String getNotes() {
	 * return notes;
	 * }
	 * public synchronized void setNotes(String notes) {
	 * this.notes = notes;
	 * }
	 * public synchronized boolean isNeedsResearch() {
	 * return needsResearch;
	 * }
	 * public synchronized void setNeedsResearch(boolean needsResearch) {
	 * this.needsResearch = needsResearch;
	 * }
	 * public synchronized boolean isNeedsPhotoEdit() {
	 * return needsPhotoEdit;
	 * }
	 * public synchronized void setNeedsPhotoEdit(boolean needsPhotoEdit) {
	 * this.needsPhotoEdit = needsPhotoEdit;
	 * }
	 * public synchronized boolean isNeedsFootage() {
	 * return needsFootage;
	 * }
	 * public synchronized void setNeedsFootage(boolean needsFootage) {
	 * this.needsFootage = needsFootage;
	 * }
	 * public synchronized boolean isNeedsLegal() {
	 * return needsLegal;
	 * }
	 * public synchronized void setNeedsLegal(boolean needsLegal) {
	 * this.needsLegal = needsLegal;
	 * }
	 * public synchronized boolean isApprResearch() {
	 * return apprResearch;
	 * }
	 * public synchronized void setApprResearch(boolean apprResearch) {
	 * this.apprResearch = apprResearch;
	 * }
	 * public synchronized boolean isApprLegal() {
	 * return apprLegal;
	 * }
	 * public synchronized void setApprLegal(boolean apprLegal) {
	 * this.apprLegal = apprLegal;
	 * }
	 * public synchronized boolean isApprPhotoEdit() {
	 * return apprPhotoEdit;
	 * }
	 * public synchronized boolean isApprFootage() {
	 * return apprFootage;
	 * }
	 * public synchronized GrfxOrder getGrfxOrder() {
	 * return grfxOrder;
	 * }
	 * public synchronized void setGrfxOrder(GrfxOrder parentOrder) {
	 * this.grfxOrder = parentOrder;
	 * }
	 * public void updateSQLItem() {
	 * try {
	 * GFXSQL.alterItem(this);
	 * } catch (SQLException e) {
	 * e.printStackTrace();
	 * }
	 * }
	 * public String toString() {
	 * String str = "\n";
	 * if (!filename.isEmpty()) {
	 * str += " Filename:  " + filename.toString() + "\n";
	 * }
	 * if (!textList.isEmpty()) {
	 * str += "\n Text: \n " + textList.toString() + "\n";
	 * }
	 * if (!stillList.isEmpty()) {
	 * str += "\n Photos: \n " + stillList.toString() + "\n";
	 * }
	 * if (!footageList.isEmpty()) {
	 * str += "\n Footage: \n " + footageList.toString() + "\n";
	 * }
	 * return str;
	 * }
	 * public String toPrint() {
	 * String str = "\n";
	 * if (!filename.isEmpty()) {
	 * str += "\n   Filename:  " + filename.toPrint() + "\n";
	 * }
	 * if (!textList.isEmpty()) {
	 * str += "\n   Text: \n " + textList.toPrint() + "\n";
	 * }
	 * if (!stillList.isEmpty()) {
	 * str += "\n   Photos: \n " + stillList.toPrint() + "\n";
	 * }
	 * if (!footageList.isEmpty()) {
	 * str += "\n   Footage: \n " + footageList.toPrint() + "\n";
	 * }
	 * return str;
	 * }
	 * @Override
	 * public int hashCode() {
	 * final int prime = 31;
	 * int result = 1;
	 * result = prime * result + (apprFootage ? 1231 : 1237);
	 * result = prime * result + (apprLegal ? 1231 : 1237);
	 * result = prime * result + (apprPhotoEdit ? 1231 : 1237);
	 * result = prime * result + (apprResearch ? 1231 : 1237);
	 * result = prime * result + ((filename == null) ? 0 : filename.hashCode());
	 * result = prime * result + ((footageList == null) ? 0 : footageList.hashCode());
	 * result = prime * result + idItem;
	 * result = prime * result + (needsFootage ? 1231 : 1237);
	 * result = prime * result + (needsLegal ? 1231 : 1237);
	 * result = prime * result + (needsPhotoEdit ? 1231 : 1237);
	 * result = prime * result + (needsResearch ? 1231 : 1237);
	 * result = prime * result + ((notes == null) ? 0 : notes.hashCode());
	 * result = prime * result + ((stillList == null) ? 0 : stillList.hashCode());
	 * result = prime * result + ((textList == null) ? 0 : textList.hashCode());
	 * return result;
	 * }
	 * @Override
	 * public boolean equals(Object obj) {
	 * if (this == obj)
	 * return true;
	 * if (obj == null)
	 * return false;
	 * if (getClass() != obj.getClass())
	 * return false;
	 * GrfxItem other = (GrfxItem) obj;
	 * if (apprFootage != other.apprFootage)
	 * return false;
	 * if (apprLegal != other.apprLegal)
	 * return false;
	 * if (apprPhotoEdit != other.apprPhotoEdit)
	 * return false;
	 * if (apprResearch != other.apprResearch)
	 * return false;
	 * if (filename == null) {
	 * if (other.filename != null)
	 * return false;
	 * } else if (!filename.equals(other.filename))
	 * return false;
	 * if (footageList == null) {
	 * if (other.footageList != null)
	 * return false;
	 * } else if (!footageList.equals(other.footageList))
	 * return false;
	 * if (idItem != other.idItem)
	 * return false;
	 * if (needsFootage != other.needsFootage)
	 * return false;
	 * if (needsLegal != other.needsLegal)
	 * return false;
	 * if (needsPhotoEdit != other.needsPhotoEdit)
	 * return false;
	 * if (needsResearch != other.needsResearch)
	 * return false;
	 * if (notes == null) {
	 * if (other.notes != null)
	 * return false;
	 * } else if (!notes.equals(other.notes))
	 * return false;
	 * if (stillList == null) {
	 * if (other.stillList != null)
	 * return false;
	 * } else if (!stillList.equals(other.stillList))
	 * return false;
	 * if (textList == null) {
	 * if (other.textList != null)
	 * return false;
	 * } else if (!textList.equals(other.textList))
	 * return false;
	 * return true;
	 * }
	 */
}
